import {baseUrl} from './config.js'
// 封装的首页榜单的网络请求
export function topList(){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `${baseUrl}/toplist/detail`,
			methods:'GET',
			data:{
				
			},
			success: res => {
				let result = res.data.list
				result.length = 4
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}

// 封装的首页榜单下属榜单信息的网络请求
export function playerList(id){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/playlist/detail?id=${id}`,
			methods:'GET',
			data:{
				
			},
			success: res => {
				let result = res.data.playlist
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}
export function playersList(id){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/playlist/detail?id=${id}`,
			methods:'GET',
			success: res => {
				let result = res.data.playlist.tracks
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
	
			}
		})
	})
}
export function listInfo(id){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/playlist/detail?id=${id}`,
			methods:'GET',
			success: res => {
				let result = res.data.playlist
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}

export function plyerInfo(id){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/song/detail?ids=${id}`,
			methods:'GET',
			success: res => {
				let result = res.data.songs
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}
export function simiPlayer(id){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/simi/song?id=${id}`,
			methods:'GET',
			data:{
				
			},
			success: res => {
				let result = res.data.songs
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}
export function comment(id){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/comment/music?id=${id}`,
			methods:'GET',
			data:{
				
			},
			success: res => {
				let result = res.data.hotComments
				result.length = 8
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}
export function lyric(id){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/lyric?id=${id}`,
			methods:'GET',
			success: res => {
				let result = res.data.lrc.lyric
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}
export function song(id){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/song/url?id=${id}`,
			methods:'GET',
			success: res => {
				let result = res.data.data[0]
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}
export function searchHot(){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/search/hot/detail`,
			methods:'GET',
			success: res => {
				let result = res.data.data
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}
export function search(value){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/cloudsearch?keywords=${value}`,
			methods:'GET',
			success: res => {
				let result = res.data.result.songs
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}
export function searchSuggest(value){
	 return new Promise(function(reslove, reject){
		uni.request({
			url: `http://localhost:3000/search/suggest?keywords=${value}&type=mobile`,
			methods:'GET',
			success: res => {
				let result = res.data.result.allMatch
				reslove(result)
			},
			fail: () =>{
				
			},
			compele: () => {
				
			}
		})
	})
}
